﻿using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using ALDIOrganizer.Properties;
using Generator;

namespace ALDIOrganizer
{
    /* I don't use "magic pushbuttons". Methods used by event handlers -
     * methods that access SQLite database - are used here */
    public partial class MainForm
    {
        private void GoToNeighbouringRota(RelativePosition pWhich)
        {
            var neighbour = Program.CurrentFile.GetNeighbouringRota(
                CurrentRota,
                pWhich);
            if (neighbour == null)
            {
                return;
            }
            PerformAction(
                neighbour,
                neighbour.ProperAction);
            svRota.Refresh();
        }

        private void SetStatusOnCurrentRota(SpecialDayStatus pWhichOne)
        {
            if (CurrentRota == null ||
                CurrentRota.IsEmpty)
            {
                return;
            }
            var dialogCaption = String.Empty;
            var dialogMessage = String.Empty;
            switch (pWhichOne)
            {
                case SpecialDayStatus.Inventory:
                    {
                        dialogCaption = Resources.STATUSCaption_Inventory;
                        dialogMessage = Resources.STATUSGroupbox_Inventory;
                        break;
                    }
                case SpecialDayStatus.Shut:
                    {
                        dialogCaption = Resources.STATUSCaption_Shut;
                        dialogMessage = Resources.STATUSGroupbox_Shut;
                        break;
                    }                
            }
            Program.specialStatusForm = new SetDayStatus(
                dialogCaption,
                dialogMessage,
                CurrentRota.StatusesAsBoolArray(pWhichOne));
            if (Program.specialStatusForm.ShowDialog() == DialogResult.OK)
            {
                CurrentRota.SetSpecialStatus(
                    pWhichOne,
                    Program.specialStatusForm.GetDays);
            }
        }
    }
}
